/*
 * @Author: fishroom
 * @Date: 2021-08-22 20:48:09
 * @LastEditTime: 2021-09-04 12:23:35
 * @FilePath: \backstage\src\store\property\property.js
 */

import axios from "axios";

//资产页面请求
export function getPropertySelect({ commit }) {
  axios.get("/api/zl/area/queryArea").then(res => {
    commit("getPropertySelectList", res.data.data);
  });
}

// 获取分页所有数据
export function getPropertyItem({ commit }, obj) {
  axios
    .get(
      "/api/front/zuoLuo/queryZuoLuo?" +
        "page=" +
        obj.page +
        "&" +
        "limit=" +
        obj.limit
    )
    .then(res => {
      console.log(res);
      commit("getPropertyItemList", {
        list: res.data.data.list,
        length: res.data.data.total
      });
    });
}

// 获取酒店信息
export function getPropertyHotelItem({ commit }, obj) {
  axios
    .get(
      "/api/zl/queryHotel?" +
        "pageNum=" +
        obj.page +
        "&" +
        "pageSize=" +
        obj.limit
    )
    .then(res => {
      console.log("hotel", res);
      commit("getPropertyItemList", {
        list: res.data.data.list,
        length: res.data.data.total
      });
    });
}
// 获取靶场信息
export function getPropertyRangeItem({ commit }, obj) {
  axios
    .get(
      "/api/zl/range/queryRange?" +
        "pageNum=" +
        obj.page +
        "&" +
        "pageSize=" +
        obj.limit
    )
    .then(res => {
      commit("getPropertyItemList", {
        list: res.data.data.list,
        length: res.data.data.total
      });
    });
}
// 获取养殖场信息
export function getPropertyFarmItem({ commit }, obj) {
  axios
    .get(
      "/api/zl/farm/queryFarm?" +
        "pageNum=" +
        obj.page +
        "&" +
        "pageSize=" +
        obj.limit
    )
    .then(res => {
      commit("getPropertyItemList", {
        list: res.data.data.list,
        length: res.data.data.total
      });
    });
}
// 获取营房信息
export function getPropertyBarracksItem({ commit }, obj) {
  axios
    .get(
      "/api/zl/campsite/queryCampsite?" +
        "pageNum=" +
        obj.page +
        "&" +
        "pageSize=" +
        obj.limit
    )
    .then(res => {
      commit("getPropertyItemList", {
        list: res.data.data.list,
        length: res.data.data.total
      });
    });
}
// 获取楼栋信息
export function getPropertyBuildingItem({ commit }, obj) {
  axios
    .get(
      "/api/zl/building/queryBuilding?" +
        "pageNum=" +
        obj.page +
        "&" +
        "pageSize=" +
        obj.limit
    )
    .then(res => {
      commit("getPropertyItemList", {
        list: res.data.data.list,
        length: res.data.data.total
      });
    });
}
// 获取类型信息
export function getTypeItem({ commit }) {
  axios
    .post("/api/zl/dictionary/findDicByDictionaryId?" + "dictionaryId=" + 1)
    .then(res => {
      commit("getType", res.data.data);
    });
}
// 获取类型信息
export function getEvlItem({ commit }) {
  axios
    .post("/api/zl/dictionary/findDicByDictionaryId?" + "dictionaryId=" + 2)
    .then(res => {
      commit("getEvl", res.data.data);
    });
}

export function getProQueryItem({ commit }, obj) {
  axios
    .get("/api/front/zuoLuo/queryZuoLuo", {
      params: {
        provinceId: obj.provinceId,
        cityId: obj.cityId,
        districtId: obj.districtId,
        typeId: obj.typeId,
        environmentId: obj.environmentId,
        start: obj.start,
        end: obj.end,
        page: obj.page,
        limit: obj.limit
      }
    })
    .then(res => {
      console.log(res);
      commit("ProQueryItem", res.data.data.list);
    });
}

// 根据id获取详情
export function getDetailItem({ commit }, id) {
  axios
    .get("/api/front/zuoLuo/queryZuoLuoParticulars", {
      params: {
        zlId: id
      }
    })
    .then(res => {
      console.log("de", res);
      commit("getDetail", res.data.data);
    });
}
